package kmp;

public class ReplaceKongGe {

    public  static  String replaceSpace(StringBuffer  stringBuffer){
        int length = stringBuffer.length();
        StringBuffer result= new StringBuffer();
        for (int i = 0; i < length; i++) {
            char b = stringBuffer.charAt(i);
            if (String.valueOf(b).equals(" ")){
                result.append("%20");
            }else {
                result.append(b);
            }
        }
        return result.toString();
    }

    public static  String replaceSpace1(StringBuffer str){
        return  str.toString().replace(" ","%20");
    }

    public static void main(String[] args) {
        System.out.println(ReplaceKongGe.replaceSpace1(new StringBuffer("a b")));
    }
}
